package com.work.xxzl.mvp.presenter;

import com.work.xxzl.bean.CommonBean;
import com.work.xxzl.mvp.base.BaseMVPPresenter;
import com.work.xxzl.mvp.callback.MvpCallback;
import com.work.xxzl.mvp.contract.LoginContract;
import com.work.xxzl.mvp.model.LoginModel;

/**
 * author: Wangzhan
 * date :2018/9/17 0017 11:33
 * version:2.0.0
 * description:登录
 */

public class LoginPresenter extends BaseMVPPresenter<LoginContract.View> implements LoginContract.Presenter {
    private LoginContract.View view;
    private LoginContract.Model model;

    public LoginPresenter(LoginContract.View view) {
        this.view = view;
        model = new LoginModel();
    }

    @Override
    public void login(String name, String password) {
        view.showLoading();
        model.login(name, password, new MvpCallback<CommonBean>() {
            @Override
            public void onSuccess(CommonBean data) {
                view.onSuccess(0,data);
            }

            @Override
            public void onFailure(int errorcode, String msg) {
                view.onfailed(errorcode,msg);
            }

            @Override
            public void onComplete() {
                view.hideLoading();
            }

        });
    }

}
